package com.wyt.controller;

import com.wyt.dao.EmployeeMapper;
import com.wyt.entity.Employee;
import com.wyt.until.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @program: xiangmu01
 * @description: 用于登录界面的判定
 * @author: 王一同
 * @create: 2021-11-21 13:27
 **/
@RestController
public class LoginController {
    @Autowired
    private EmployeeMapper employeeMapper;

    @RequestMapping("login")
    public CommonResult login (String enumber, String password, HttpSession session){
        Employee login = employeeMapper.login(enumber, password);
        if(login.geteNumber()!=null){
            session.setAttribute("login",login);
            CommonResult commonResult = new CommonResult(200,"欢迎您!"+login.geteName(),login);
            return commonResult;
        }
        CommonResult commonResult1 = new CommonResult(500,"好像出错了",login);
        return commonResult1;
    }
}
